package com.sphd.restaurantsystem.adapters;

import android.content.Context;
import android.util.Log;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.restaurantsystem.R;
import com.sphd.restaurantsystem.info.ConsumeInfo;
import com.sphd.restaurantsystem.utils.Constant;
import com.wzh.frame.utils.BigDisMailUtils;
import com.wzh.frame.utils.TimeUtils;

import java.util.List;

/**
 * Created by Hu on 2016/11/10.
 */

public class ConsumeAdapter extends BaseQuickAdapter<ConsumeInfo> {
    Context context;

    public ConsumeAdapter(int layoutResId, List<ConsumeInfo> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ConsumeInfo consumeInfo) {
        Log.e("sssss=====", consumeInfo.getOrder_pay() + "");
        baseViewHolder.setText(R.id.consume_time, TimeUtils.getTime(consumeInfo.getOrder_fintime(), TimeUtils.DATE_FORMAT_DATE))
                .setText(R.id.type_consume, (consumeInfo.getOrder_isosale() == 0) ? "店内消费" : (consumeInfo.getOrder_isosale() == 1) ? "店外消费"
                        : "录入订单")
                .setText(R.id.type_pay_textview, consumeInfo.getOrder_pay() == 0 ? "现" : "充")
                .setBackgroundColor(R.id.type_pay_textview, consumeInfo.getOrder_pay() == 0 ? context.getResources().getColor(R.color.red) :
                        context.getResources().getColor(R.color.indigo_500))

                .setText(R.id.money_pay_textview, "现金支付￥" + BigDisMailUtils.turnTrim(consumeInfo.getOrder_lastprice(), Constant.DECIMAL_POINT_TWO))
                .setText(R.id.card_pay_textview, "充值卡支付￥" + BigDisMailUtils.turnTrim(consumeInfo.getOrder_cardpay(),Constant.DECIMAL_POINT_TWO));

    }
}
